var express = require('express');
var app = express();

var router = require(__dirname+"/routes");

app.set('port',process.env.PORT || 3000);

//设置路由
router(app);

//定义400
app.use(function(req,res) {
  res.type("text/plain")
  res.status(400)
  res.send('404 - Not Found')
});

//定义500
app.use(function(err,req,res,next){
  console.log(err.stack);
  res.type('text/plain')
  res.status(500)
  res.send('500 - Server Error')
});

//设定端口
app.listen(app.get('port'),function(){
  console.log("express started on http://localhost:"+app.get('port'))
})